home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UNIXTOOL / GNU / FLEX / FLEX~ / man / flexdoc_tx < prev   
Text File  |  1989-04-15  |  77KB  |  2,046 lines

  1.  
  2.  
  3.  
  4.    26 May 1990                                                        FLEX(1)
  5.  
  6.  
  7.  
  8.    NAME
  9.      flex - fast lexical analyzer generator
  10.  
  11.    SYNOPSIS
  12.      flex [-bcdfinpstvFILT8 -C[efmF] -Sskeleton] [filename ...]
  13.  
  14.    DESCRIPTION
  15.      flex is a tool for generating scanners: programs which recognized lexi-
  16.      cal patterns in text.  flex reads the given input files, or its standard
  17.      input if no file names are given, for a description of a scanner to gen-
  18.      erate.  The description is in the form of pairs of regular expressions
  19.      and C code, called rules. flex generates as output a C source file,
  20.      lex.yy.c, which defines a routine yylex(). This file is compiled and
  21.      linked with the -lfl library to produce an executable.  When the execut-
  22.      able is run, it analyzes its input for occurrences of the regular
  23.      expressions.  Whenever it finds one, it executes the corresponding C
  24.      code.
  25.  
  26.    SOME SIMPLE EXAMPLES
  27.  
  28.      First some simple examples to get the flavor of how one uses flex. The
  29.      following flex input specifies a scanner which whenever it encounters
  30.      the string "username" will replace it with the user's login name:
  31.  
  32.          %%
  33.          username    printf( "%s", getlogin() );
  34.  
  35.      By default, any text not matched by a flex scanner is copied to the out-
  36.      put, so the net effect of this scanner is to copy its input file to its
  37.      output with each occurrence of "username" expanded.  In this input,
  38.      there is just one rule.  "username" is the pattern and the "printf" is
  39.      the action. The "%%" marks the beginning of the rules.
  40.  
  41.      Here's another simple example:
  42.  
  43.              int num_lines = 0, num_chars = 0;
  44.  
  45.          %%
  46.          \n    ++num_lines; ++num_chars;
  47.          .     ++num_chars;
  48.  
  49.          %%
  50.          main()
  51.              {
  52.              yylex();
  53.              printf( "# of lines = %d, # of chars = %d\n",
  54.                      num_lines, num_chars );
  55.              }
  56.  
  57.      This scanner counts the number of characters and the number of lines in
  58.      its input (it produces no output other than the final report on the
  59.      counts).  The first line declares two globals, "num_lines" and
  60.      "num_chars", which are accessible both inside yylex() and in the main()
  61.  
  62.  
  63.    Version 2.3                                                              1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.    FLEX(1)                                                        26 May 1990
  71.  
  72.  
  73.      routine declared after the second "%%".  There are two rules, one which
  74.      matches a newline ("\n") and increments both the line count and the
  75.      character count, and one which matches any character other than a new-
  76.      line (indicated by the "." regular expression).
  77.  
  78.      A somewhat more complicated example:
  79.  
  80.          /* scanner for a toy Pascal-like language */
  81.  
  82.          %{
  83.          /* need this for the call to atof() below */
  84.          #include <math.h>
  85.          %}
  86.  
  87.          DIGIT    [0-9]
  88.          ID       [a-z][a-z0-9]*
  89.  
  90.          %%
  91.  
  92.          {DIGIT}+    {
  93.                      printf( "An integer: %s (%d)\n", yytext,
  94.                              atoi( yytext ) );
  95.                      }
  96.  
  97.          {DIGIT}+"."{DIGIT}*        {
  98.                      printf( "A float: %s (%g)\n", yytext,
  99.                              atof( yytext ) );
  100.                      }
  101.  
  102.          if|then|begin|end|procedure|function        {
  103.                      printf( "A keyword: %s\n", yytext );
  104.                      }
  105.  
  106.          {ID}        printf( "An identifier: %s\n", yytext );
  107.  
  108.          "+"|"-"|"*"|"/"   printf( "An operator: %s\n", yytext );
  109.  
  110.          "{"[^}\n]*"}"     /* eat up one-line comments */
  111.  
  112.          [ \t\n]+          /* eat up whitespace */
  113.  
  114.          .           printf( "Unrecognized character: %s\n", yytext );
  115.  
  116.          %%
  117.  
  118.          main( argc, argv )
  119.          int argc;
  120.          char **argv;
  121.              {
  122.              ++argv, --argc;  /* skip over program name */
  123.              if ( argc > 0 )
  124.                      yyin = fopen( argv[0], "r" );
  125.              else
  126.                      yyin = stdin;
  127.  
  128.  
  129.    2                                                              Version 2.3
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.    26 May 1990                                                        FLEX(1)
  137.  
  138.  
  139.  
  140.              yylex();
  141.              }
  142.  
  143.      This is the beginnings of a simple scanner for a language like Pascal.
  144.      It identifies different types of tokens and reports on what it has seen.
  145.  
  146.      The details of this example will be explained in the following sections.
  147.  
  148.    FORMAT OF THE INPUT FILE
  149.      The flex input file consists of three sections, separated by a line with
  150.      just %% in it:
  151.  
  152.          definitions
  153.          %%
  154.          rules
  155.          %%
  156.          user code
  157.  
  158.      The definitions section contains declarations of simple name definitions
  159.      to simplify the scanner specification, and declarations of start condi-
  160.      tions, which are explained in a later section.
  161.  
  162.      Name definitions have the form:
  163.  
  164.          name definition
  165.  
  166.      The "name" is a word beginning with a letter or an underscore ('_') fol-
  167.      lowed by zero or more letters, digits, '_', or '-' (dash).  The defini-
  168.      tion is taken to begin at the first non-white-space character following
  169.      the name and continuing to the end of the line.  The definition can sub-
  170.      sequently be referred to using "{name}", which will expand to "(defini-
  171.      tion)".  For example,
  172.  
  173.          DIGIT    [0-9]
  174.          ID       [a-z][a-z0-9]*
  175.  
  176.      defines "DIGIT" to be a regular expression which matches a single digit,
  177.      and "ID" to be a regular expression which matches a letter followed by
  178.      zero-or-more letters-or-digits.  A subsequent reference to
  179.  
  180.          {DIGIT}+"."{DIGIT}*
  181.  
  182.      is identical to
  183.  
  184.          ([0-9])+"."([0-9])*
  185.  
  186.      and matches one-or-more digits followed by a '.' followed by zero-or-
  187.      more digits.
  188.  
  189.      The rules section of the flex input contains a series of rules of the
  190.      form:
  191.  
  192.          pattern   action
  193.  
  194.  
  195.    Version 2.3                                                              3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.    FLEX(1)                                                        26 May 1990
  203.  
  204.  
  205.  
  206.      where the pattern must be unindented and the action must begin on the
  207.      same line.
  208.  
  209.      See below for a further description of patterns and actions.
  210.  
  211.      Finally, the user code section is simply copied to lex.yy.c verbatim.
  212.      It is used for companion routines which call or are called by the
  213.      scanner.  The presence of this section is optional; if it is missing,
  214.      the second %% in the input file may be skipped, too.
  215.  
  216.      In the definitions and rules sections, any indented text or text
  217.      enclosed in %{ and %} is copied verbatim to the output (with the %{}'s
  218.      removed).  The %{}'s must appear unindented on lines by themselves.
  219.  
  220.      In the rules section, any indented or %{} text appearing before the
  221.      first rule may be used to declare variables which are local to the scan-
  222.      ning routine and (after the declarations) code which is to be executed
  223.      whenever the scanning routine is entered.  Other indented or %{} text in
  224.      the rule section is still copied to the output, but its meaning is not
  225.      well-defined and it may well cause compile-time errors (this feature is
  226.      present for POSIX compliance; see below for other such features).
  227.  
  228.      In the definitions section, an unindented comment (i.e., a line begin-
  229.      ning with "/*") is also copied verbatim to the output up to the next
  230.      "*/".  Also, any line in the definitions section beginning with '#' is
  231.      ignored, though this style of comment is deprecated and may go away in
  232.      the future.
  233.  
  234.    PATTERNS
  235.      The patterns in the input are written using an extended set of regular
  236.      expressions.  These are:
  237.  
  238.          x          match the character 'x'
  239.          .          any character except newline
  240.          [xyz]      a "character class"; in this case, the pattern
  241.                       matches either an 'x', a 'y', or a 'z'
  242.          [abj-oZ]   a "character class" with a range in it; matches
  243.                       an 'a', a 'b', any letter from 'j' through 'o',
  244.                       or a 'Z'
  245.          [^A-Z]     a "negated character class", i.e., any character
  246.                       but those in the class.  In this case, any
  247.                       character EXCEPT an uppercase letter.
  248.          [^A-Z\n]   any character EXCEPT an uppercase letter or
  249.                       a newline
  250.          r*         zero or more r's, where r is any regular expression
  251.          r+         one or more r's
  252.          r?         zero or one r's (that is, "an optional r")
  253.          r{2,5}     anywhere from two to five r's
  254.          r{2,}      two or more r's
  255.          r{4}       exactly 4 r's
  256.          {name}     the expansion of the "name" definition
  257.                     (see above)
  258.          "[xyz]\"foo"
  259.  
  260.  
  261.    4                                                              Version 2.3
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.    26 May 1990                                                        FLEX(1)
  269.  
  270.  
  271.                     the literal string: [xyz]"foo
  272.          \X         if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v',
  273.                       then the ANSI-C interpretation of \x.
  274.                       Otherwise, a literal 'X' (used to escape
  275.                       operators such as '*')
  276.          \123       the character with octal value 123
  277.          \x2a       the character with hexadecimal value 2a
  278.          (r)        match an r; parentheses are used to override
  279.                       precedence (see below)
  280.  
  281.  
  282.          rs         the regular expression r followed by the
  283.                       regular expression s; called "concatenation"
  284.  
  285.  
  286.          r|s        either an r or an s
  287.  
  288.  
  289.          r/s        an r but only if it is followed by an s.  The
  290.                       s is not part of the matched text.  This type
  291.                       of pattern is called as "trailing context".
  292.          ^r         an r, but only at the beginning of a line
  293.          r$         an r, but only at the end of a line.  Equivalent
  294.                       to "r/\n".
  295.  
  296.  
  297.          <s>r       an r, but only in start condition s (see
  298.                     below for discussion of start conditions)
  299.          <s1,s2,s3>r
  300.                     same, but in any of start conditions s1,
  301.                     s2, or s3
  302.  
  303.  
  304.          <<EOF>>    an end-of-file
  305.          <s1,s2><<EOF>>
  306.                     an end-of-file when in start condition s1 or s2
  307.  
  308.      The regular expressions listed above are grouped according to pre-
  309.      cedence, from highest precedence at the top to lowest at the bottom.
  310.      Those grouped together have equal precedence.  For example,
  311.  
  312.          foo|bar*
  313.  
  314.      is the same as
  315.  
  316.          (foo)|(ba(r*))
  317.  
  318.      since the '*' operator has higher precedence than concatenation, and
  319.      concatenation higher than alternation ('|').  This pattern therefore
  320.      matches either the string "foo" or the string "ba" followed by zero-or-
  321.      more r's.  To match "foo" or zero-or-more "bar"'s, use:
  322.  
  323.          foo|(bar)*
  324.  
  325.  
  326.  
  327.    Version 2.3                                                              5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.    FLEX(1)                                                        26 May 1990
  335.  
  336.  
  337.      and to match zero-or-more "foo"'s-or-"bar"'s:
  338.  
  339.          (foo|bar)*
  340.  
  341.  
  342.      Some notes on patterns:
  343.  
  344.      -    A negated character class such as the example "[^A-Z]" above will
  345.           match a newline unless "\n" (or an equivalent escape sequence) is
  346.           one of the characters explicitly present in the negated character
  347.           class (e.g., "[^A-Z\n]").  This is unlike how many other regular
  348.           expression tools treat negated character classes, but unfortunately
  349.           the inconsistency is historically entrenched.  Matching newlines
  350.           means that a pattern like [^"]* can match an entire input (over-
  351.           flowing the scanner's input buffer) unless there's another quote in
  352.           the input.
  353.  
  354.      -    A rule can have at most one instance of trailing context (the '/'
  355.           operator or the '$' operator).  The start condition, '^', and
  356.           "<<EOF>>" patterns can only occur at the beginning of a pattern,
  357.           and, as well as with '/' and '$', cannot be grouped inside
  358.           parentheses.  A '^' which does not occur at the beginning of a rule
  359.           or a '$' which does not occur at the end of a rule loses its spe-
  360.           cial properties and is treated as a normal character.
  361.  
  362.           The following are illegal:
  363.  
  364.               foo/bar$
  365.               <sc1>foo<sc2>bar
  366.  
  367.           Note that the first of these, can be written "foo/bar\n".
  368.  
  369.           The following will result in '$' or '^' being treated as a normal
  370.           character:
  371.  
  372.               foo|(bar$)
  373.               foo|^bar
  374.  
  375.           If what's wanted is a "foo" or a bar-followed-by-a-newline, the
  376.           following could be used (the special '|' action is explained
  377.           below):
  378.  
  379.               foo      |
  380.               bar$     /* action goes here */
  381.  
  382.           A similar trick will work for matching a foo or a bar-at-the-
  383.           beginning-of-a-line.
  384.  
  385.    HOW THE INPUT IS MATCHED
  386.      When the generated scanner is run, it analyzes its input looking for
  387.      strings which match any of its patterns.  If it finds more than one
  388.      match, it takes the one matching the most text (for trailing context
  389.      rules, this includes the length of the trailing part, even though it
  390.      will then be returned to the input).  If it finds two or more matches of
  391.  
  392.  
  393.    6                                                              Version 2.3
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.    26 May 1990                                                        FLEX(1)
  401.  
  402.  
  403.      the same length, the rule listed first in the flex input file is chosen.
  404.  
  405.      Once the match is determined, the text corresponding to the match
  406.      (called the token) is made available in the global character pointer
  407.      yytext, and its length in the global integer yyleng. The action
  408.      corresponding to the matched pattern is then executed (a more detailed
  409.      description of actions follows), and then the remaining input is scanned
  410.      for another match.
  411.  
  412.      If no match is found, then the default rule is executed: the next char-
  413.      acter in the input is considered matched and copied to the standard out-
  414.      put.  Thus, the simplest legal flex input is:
  415.  
  416.          %%
  417.  
  418.      which generates a scanner that simply copies its input (one character at
  419.      a time) to its output.
  420.  
  421.    ACTIONS
  422.      Each pattern in a rule has a corresponding action, which can be any
  423.      arbitrary C statement.  The pattern ends at the first non-escaped whi-
  424.      tespace character; the remainder of the line is its action.  If the
  425.      action is empty, then when the pattern is matched the input token is
  426.      simply discarded.  For example, here is the specification for a program
  427.      which deletes all occurrences of "zap me" from its input:
  428.  
  429.          %%
  430.          "zap me"
  431.  
  432.      (It will copy all other characters in the input to the output since they
  433.      will be matched by the default rule.)
  434.  
  435.      Here is a program which compresses multiple blanks and tabs down to a
  436.      single blank, and throws away whitespace found at the end of a line:
  437.  
  438.          %%
  439.          [ \t]+        putchar( ' ' );
  440.          [ \t]+$       /* ignore this token */
  441.  
  442.  
  443.      If the action contains a '{', then the action spans till the balancing
  444.      '}' is found, and the action may cross multiple lines.  flex knows about
  445.      C strings and comments and won't be fooled by braces found within them,
  446.      but also allows actions to begin with %{ and will consider the action to
  447.      be all the text up to the next %} (regardless of ordinary braces inside
  448.      the action).
  449.  
  450.      An action consisting solely of a vertical bar ('|') means "same as the
  451.      action for the next rule."  See below for an illustration.
  452.  
  453.      Actions can include arbitrary C code, including return statements to
  454.      return a value to whatever routine called yylex(). Each time yylex() is
  455.      called it continues processing tokens from where it last left off until
  456.      it either reaches the end of the file or executes a return.  Once it
  457.  
  458.  
  459.    Version 2.3                                                              7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.    FLEX(1)                                                        26 May 1990
  467.  
  468.  
  469.      reaches an end-of-file, however, then any subsequent call to yylex()
  470.      will simply immediately return, unless yyrestart() is first called (see
  471.      below).
  472.  
  473.      Actions are not allowed to modify yytext or yyleng.
  474.  
  475.      There are a number of special directives which can be included within an
  476.      action:
  477.  
  478.      -    ECHO copies yytext to the scanner's output.
  479.  
  480.      -    BEGIN followed by the name of a start condition places the scanner
  481.           in the corresponding start condition (see below).
  482.  
  483.      -    REJECT directs the scanner to proceed on to the "second best" rule
  484.           which matched the input (or a prefix of the input).  The rule is
  485.           chosen as described above in "How the Input is Matched", and yytext
  486.           and yyleng set up appropriately.  It may either be one which
  487.           matched as much text as the originally chosen rule but came later
  488.           in the flex input file, or one which matched less text.  For exam-
  489.           ple, the following will both count the words in the input and call
  490.           the routine special() whenever "frob" is seen:
  491.  
  492.                       int word_count = 0;
  493.               %%
  494.  
  495.               frob        special(); REJECT;
  496.               [^ \t\n]+   ++word_count;
  497.  
  498.           Without the REJECT, any "frob"'s in the input would not be counted
  499.           as words, since the scanner normally executes only one action per
  500.           token.  Multiple REJECT's are allowed, each one finding the next
  501.           best choice to the currently active rule.  For example, when the
  502.           following scanner scans the token "abcd", it will write "abcdab-
  503.           caba" to the output:
  504.  
  505.               %%
  506.               a        |
  507.               ab       |
  508.               abc      |
  509.               abcd     ECHO; REJECT;
  510.               .|\n     /* eat up any unmatched character */
  511.  
  512.           (The first three rules share the fourth's action since they use the
  513.           special '|' action.) REJECT is a particularly expensive feature in
  514.           terms scanner performance; if it is used in any of the scanner's
  515.           actions it will slow down all of the scanner's matching.  Further-
  516.           more, REJECT cannot be used with the -f or -F options (see below).
  517.  
  518.           Note also that unlike the other special actions, REJECT is a
  519.           branch; code immediately following it in the action will not be
  520.           executed.
  521.  
  522.      -    yymore() tells the scanner that the next time it matches a rule,
  523.  
  524.  
  525.    8                                                              Version 2.3
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.    26 May 1990                                                        FLEX(1)
  533.  
  534.  
  535.           the corresponding token should be appended onto the current value
  536.           of yytext rather than replacing it.  For example, given the input
  537.           "mega-kludge" the following will write "mega-mega-kludge" to the
  538.           output:
  539.  
  540.               %%
  541.               mega-    ECHO; yymore();
  542.               kludge   ECHO;
  543.  
  544.           First "mega-" is matched and echoed to the output.  Then "kludge"
  545.           is matched, but the previous "mega-" is still hanging around at the
  546.           beginning of yytext so the ECHO for the "kludge" rule will actually
  547.           write "mega-kludge".  The presence of yymore() in the scanner's
  548.           action entails a minor performance penalty in the scanner's match-
  549.           ing speed.
  550.  
  551.      -    yyless(n) returns all but the first n characters of the current
  552.           token back to the input stream, where they will be rescanned when
  553.           the scanner looks for the next match.  yytext and yyleng are
  554.           adjusted appropriately (e.g., yyleng will now be equal to n ).  For
  555.           example, on the input "foobar" the following will write out
  556.           "foobarbar":
  557.  
  558.               %%
  559.               foobar    ECHO; yyless(3);
  560.               [a-z]+    ECHO;
  561.  
  562.           An argument of 0 to yyless will cause the entire current input
  563.           string to be scanned again.  Unless you've changed how the scanner
  564.           will subsequently process its input (using BEGIN, for example),
  565.           this will result in an endless loop.
  566.  
  567.      -    unput(c) puts the character c back onto the input stream.  It will
  568.           be the next character scanned.  The following action will take the
  569.           current token and cause it to be rescanned enclosed in parentheses.
  570.  
  571.               {
  572.               int i;
  573.               unput( ')' );
  574.               for ( i = yyleng - 1; i >= 0; --i )
  575.                   unput( yytext[i] );
  576.               unput( '(' );
  577.               }
  578.  
  579.           Note that since each unput() puts the given character back at the
  580.           beginning of the input stream, pushing back strings must be done
  581.           back-to-front.
  582.  
  583.      -    input() reads the next character from the input stream.  For exam-
  584.           ple, the following is one way to eat up C comments:
  585.  
  586.               %%
  587.               "/*"        {
  588.                           register int c;
  589.  
  590.  
  591.    Version 2.3                                                              9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.    FLEX(1)                                                        26 May 1990
  599.  
  600.  
  601.  
  602.                           for ( ; ; )
  603.                               {
  604.                               while ( (c = input()) != '*' &&
  605.                                       c != EOF )
  606.                                   ;    /* eat up text of comment */
  607.  
  608.                               if ( c == '*' )
  609.                                   {
  610.                                   while ( (c = input()) == '*' )
  611.                                       ;
  612.                                   if ( c == '/' )
  613.                                       break;    /* found the end */
  614.                                   }
  615.  
  616.                               if ( c == EOF )
  617.                                   {
  618.                                   error( "EOF in comment" );
  619.                                   break;
  620.                                   }
  621.                               }
  622.                           }
  623.  
  624.           (Note that if the scanner is compiled using C++, then input() is
  625.           instead referred to as yyinput(), in order to avoid a name clash
  626.           with the C++ stream by the name of input.)
  627.  
  628.      -    yyterminate() can be used in lieu of a return statement in an
  629.           action.  It terminates the scanner and returns a 0 to the scanner's
  630.           caller, indicating "all done".  Subsequent calls to the scanner
  631.           will immediately return unless preceded by a call to yyrestart()
  632.           (see below).  By default, yyterminate() is also called when an
  633.           end-of-file is encountered.  It is a macro and may be redefined.
  634.  
  635.    THE GENERATED SCANNER
  636.      The output of flex is the file lex.yy.c, which contains the scanning
  637.      routine yylex(), a number of tables used by it for matching tokens, and
  638.      a number of auxiliary routines and macros.  By default, yylex() is
  639.      declared as follows:
  640.  
  641.          int yylex()
  642.              {
  643.              ... various definitions and the actions in here ...
  644.              }
  645.  
  646.      (If your environment supports function prototypes, then it will be "int
  647.      yylex( void )".)  This definition may be changed by redefining the
  648.      "YY_DECL" macro.  For example, you could use:
  649.  
  650.          #undef YY_DECL
  651.          #define YY_DECL float lexscan( a, b ) float a, b;
  652.  
  653.      to give the scanning routine the name lexscan, returning a float, and
  654.      taking two floats as arguments.  Note that if you give arguments to the
  655.  
  656.  
  657.    10                                                             Version 2.3
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.    26 May 1990                                                        FLEX(1)
  665.  
  666.  
  667.      scanning routine using a K&R-style/non-prototyped function declaration,
  668.      you must terminate the definition with a semi-colon (;).
  669.  
  670.      Whenever yylex() is called, it scans tokens from the global input file
  671.      yyin (which defaults to stdin).  It continues until it either reaches an
  672.      end-of-file (at which point it returns the value 0) or one of its
  673.      actions executes a return statement.  In the former case, when called
  674.      again the scanner will immediately return unless yyrestart() is called
  675.      to point yyin at the new input file.  ( yyrestart() takes one argument,
  676.      a FILE * pointer.) In the latter case (i.e., when an action executes a
  677.      return), the scanner may then be called again and it will resume scan-
  678.      ning where it left off.
  679.  
  680.      By default (and for purposes of efficiency), the scanner uses block-
  681.      reads rather than simple getc() calls to read characters from yyin. The
  682.      nature of how it gets its input can be controlled by redefining the
  683.      YY_INPUT macro.  YY_INPUT's calling sequence is
  684.      "YY_INPUT(buf,result,max_size)".  Its action is to place up to max_size
  685.      characters in the character array buf and return in the integer variable
  686.      result either the number of characters read or the constant YY_NULL (0
  687.      on Unix systems) to indicate EOF.  The default YY_INPUT reads from the
  688.      global file-pointer "yyin".
  689.  
  690.      A sample redefinition of YY_INPUT (in the definitions section of the
  691.      input file):
  692.  
  693.          %{
  694.          #undef YY_INPUT
  695.          #define YY_INPUT(buf,result,max_size) \
  696.              { \
  697.              int c = getchar(); \
  698.              result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
  699.              }
  700.          %}
  701.  
  702.      This definition will change the input processing to occur one character
  703.      at a time.
  704.  
  705.      You also can add in things like keeping track of the input line number
  706.      this way; but don't expect your scanner to go very fast.
  707.  
  708.      When the scanner receives an end-of-file indication from YY_INPUT, it
  709.      then checks the yywrap() function.  If yywrap() returns false (zero),
  710.      then it is assumed that the function has gone ahead and set up yyin to
  711.      point to another input file, and scanning continues.  If it returns true
  712.      (non-zero), then the scanner terminates, returning 0 to its caller.
  713.  
  714.      The default yywrap() always returns 1.  Presently, to redefine it you
  715.      must first "#undef yywrap", as it is currently implemented as a macro.
  716.      As indicated by the hedging in the previous sentence, it may be changed
  717.      to a true function in the near future.
  718.  
  719.      The scanner writes its ECHO output to the yyout global (default,
  720.      stdout), which may be redefined by the user simply by assigning it to
  721.  
  722.  
  723.    Version 2.3                                                             11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.    FLEX(1)                                                        26 May 1990
  731.  
  732.  
  733.      some other FILE pointer.
  734.  
  735.    START CONDITIONS
  736.      flex provides a mechanism for conditionally activating rules.  Any rule
  737.      whose pattern is prefixed with "<sc>" will only be active when the
  738.      scanner is in the start condition named "sc".  For example,
  739.  
  740.          <STRING>[^"]*        { /* eat up the string body ... */
  741.                      ...
  742.                      }
  743.  
  744.      will be active only when the scanner is in the "STRING" start condition,
  745.      and
  746.  
  747.          <INITIAL,STRING,QUOTE>\.        { /* handle an escape ... */
  748.                      ...
  749.                      }
  750.  
  751.      will be active only when the current start condition is either "INI-
  752.      TIAL", "STRING", or "QUOTE".
  753.  
  754.      Start conditions are declared in the definitions (first) section of the
  755.      input using unindented lines beginning with either %s or %x followed by
  756.      a list of names.  The former declares inclusive start conditions, the
  757.      latter exclusive start conditions.  A start condition is activated using
  758.      the BEGIN action.  Until the next BEGIN action is executed, rules with
  759.      the given start condition will be active and rules with other start con-
  760.      ditions will be inactive.  If the start condition is inclusive, then
  761.      rules with no start conditions at all will also be active.  If it is
  762.      exclusive, then only rules qualified with the start condition will be
  763.      active.  A set of rules contingent on the same exclusive start condition
  764.      describe a scanner which is independent of any of the other rules in the
  765.      flex input.  Because of this, exclusive start conditions make it easy to
  766.      specify "mini-scanners" which scan portions of the input that are syn-
  767.      tactically different from the rest (e.g., comments).
  768.  
  769.      If the distinction between inclusive and exclusive start conditions is
  770.      still a little vague, here's a simple example illustrating the connec-
  771.      tion between the two.  The set of rules:
  772.  
  773.          %s example
  774.          %%
  775.          <example>foo           /* do something */
  776.  
  777.      is equivalent to
  778.  
  779.          %x example
  780.          %%
  781.          <INITIAL,example>foo   /* do something */
  782.  
  783.  
  784.      The default rule (to ECHO any unmatched character) remains active in
  785.      start conditions.
  786.  
  787.  
  788.  
  789.    12                                                             Version 2.3
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.    26 May 1990                                                        FLEX(1)
  797.  
  798.  
  799.      BEGIN(0) returns to the original state where only the rules with no
  800.      start conditions are active.  This state can also be referred to as the
  801.      start-condition "INITIAL", so BEGIN(INITIAL) is equivalent to BEGIN(0).
  802.      (The parentheses around the start condition name are not required but
  803.      are considered good style.)
  804.  
  805.      BEGIN actions can also be given as indented code at the beginning of the
  806.      rules section.  For example, the following will cause the scanner to
  807.      enter the "SPECIAL" start condition whenever yylex() is called and the
  808.      global variable enter_special is true:
  809.  
  810.                  int enter_special;
  811.  
  812.          %x SPECIAL
  813.          %%
  814.                  if ( enter_special )
  815.                      BEGIN(SPECIAL);
  816.  
  817.          <SPECIAL>blahblahblah
  818.          ...more rules follow...
  819.  
  820.  
  821.      To illustrate the uses of start conditions, here is a scanner which pro-
  822.      vides two different interpretations of a string like "123.456".  By
  823.      default it will treat it as as three tokens, the integer "123", a dot
  824.      ('.'), and the integer "456".  But if the string is preceded earlier in
  825.      the line by the string "expect-floats" it will treat it as a single
  826.      token, the floating-point number 123.456:
  827.  
  828.          %{
  829.          #include <math.h>
  830.          %}
  831.          %s expect
  832.  
  833.          %%
  834.          expect-floats        BEGIN(expect);
  835.  
  836.          <expect>[0-9]+"."[0-9]+      {
  837.                      printf( "found a float, = %f\n",
  838.                              atof( yytext ) );
  839.                      }
  840.          <expect>\n           {
  841.                      /* that's the end of the line, so
  842.                       * we need another "expect-number"
  843.                       * before we'll recognize any more
  844.                       * numbers
  845.                       */
  846.                      BEGIN(INITIAL);
  847.                      }
  848.  
  849.          [0-9]+      {
  850.                      printf( "found an integer, = %d\n",
  851.                              atoi( yytext ) );
  852.                      }
  853.  
  854.  
  855.    Version 2.3                                                             13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.    FLEX(1)                                                        26 May 1990
  863.  
  864.  
  865.  
  866.          "."         printf( "found a dot\n" );
  867.  
  868.      Here is a scanner which recognizes (and discards) C comments while main-
  869.      taining a count of the current input line.
  870.  
  871.          %x comment
  872.          %%
  873.                  int line_num = 1;
  874.  
  875.          "/*"         BEGIN(comment);
  876.  
  877.          <comment>[^*\n]*        /* eat anything that's not a '*' */
  878.          <comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
  879.          <comment>\n             ++line_num;
  880.          <comment>"*"+"/"        BEGIN(INITIAL);
  881.  
  882.      Note that start-conditions names are really integer values and can be
  883.      stored as such.  Thus, the above could be extended in the following
  884.      fashion:
  885.  
  886.          %x comment foo
  887.          %%
  888.                  int line_num = 1;
  889.                  int comment_caller;
  890.  
  891.          "/*"         {
  892.                       comment_caller = INITIAL;
  893.                       BEGIN(comment);
  894.                       }
  895.  
  896.          ...
  897.  
  898.          <foo>"/*"    {
  899.                       comment_caller = foo;
  900.                       BEGIN(comment);
  901.                       }
  902.  
  903.          <comment>[^*\n]*        /* eat anything that's not a '*' */
  904.          <comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
  905.          <comment>\n             ++line_num;
  906.          <comment>"*"+"/"        BEGIN(comment_caller);
  907.  
  908.      One can then implement a "stack" of start conditions using an array of
  909.      integers.  (It is likely that such stacks will become a full-fledged
  910.      flex feature in the future.)  Note, though, that start conditions do not
  911.      have their own name-space; %s's and %x's declare names in the same
  912.      fashion as #define's.
  913.  
  914.    MULTIPLE INPUT BUFFERS
  915.      Some scanners (such as those which support "include" files) require
  916.      reading from several input streams.  As flex scanners do a large amount
  917.      of buffering, one cannot control where the next input will be read from
  918.      by simply writing a YY_INPUT which is sensitive to the scanning context.
  919.  
  920.  
  921.    14                                                             Version 2.3
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.    26 May 1990                                                        FLEX(1)
  929.  
  930.  
  931.      YY_INPUT is only called when the scanner reaches the end of its buffer,
  932.      which may be a long time after scanning a statement such as an "include"
  933.      which requires switching the input source.
  934.  
  935.      To negotiate these sorts of problems, flex provides a mechanism for
  936.      creating and switching between multiple input buffers.  An input buffer
  937.      is created by using:
  938.  
  939.          YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  940.  
  941.      which takes a FILE pointer and a size and creates a buffer associated
  942.      with the given file and large enough to hold size characters (when in
  943.      doubt, use YY_BUF_SIZE for the size).  It returns a YY_BUFFER_STATE han-
  944.      dle, which may then be passed to other routines:
  945.  
  946.          void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  947.  
  948.      switches the scanner's input buffer so subsequent tokens will come from
  949.      new_buffer. Note that yy_switch_to_buffer() may be used by yywrap() to
  950.      sets things up for continued scanning, instead of opening a new file and
  951.      pointing yyin at it.
  952.  
  953.          void yy_delete_buffer( YY_BUFFER_STATE buffer )
  954.  
  955.      is used to reclaim the storage associated with a buffer.
  956.  
  957.      yy_new_buffer() is an alias for yy_create_buffer(), provided for compa-
  958.      tibility with the C++ use of new and delete for creating and destroying
  959.      dynamic objects.
  960.  
  961.      Finally, the YY_CURRENT_BUFFER macro returns a YY_BUFFER_STATE handle to
  962.      the current buffer.
  963.  
  964.      Here is an example of using these features for writing a scanner which
  965.      expands include files (the <<EOF>> feature is discussed below):
  966.  
  967.          /* the "incl" state is used for picking up the name
  968.           * of an include file
  969.           */
  970.          %x incl
  971.  
  972.          %{
  973.          #define MAX_INCLUDE_DEPTH 10
  974.          YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
  975.          int include_stack_ptr = 0;
  976.          %}
  977.  
  978.          %%
  979.          include             BEGIN(incl);
  980.  
  981.          [a-z]+              ECHO;
  982.          [^a-z\n]*\n?        ECHO;
  983.  
  984.          <incl>[ \t]*      /* eat the whitespace */
  985.  
  986.  
  987.    Version 2.3                                                             15
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.    FLEX(1)                                                        26 May 1990
  995.  
  996.  
  997.          <incl>[^ \t\n]+   { /* got the include file name */
  998.                  if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
  999.                      {
  1000.                      fprintf( stderr, "Includes nested too deeply" );
  1001.                      exit( 1 );
  1002.                      }
  1003.  
  1004.                  include_stack[include_stack_ptr++] =
  1005.                      YY_CURRENT_BUFFER;
  1006.  
  1007.                  yyin = fopen( yytext, "r" );
  1008.  
  1009.                  if ( ! yyin )
  1010.                      error( ... );
  1011.  
  1012.                  yy_switch_to_buffer(
  1013.                      yy_create_buffer( yyin, YY_BUF_SIZE ) );
  1014.  
  1015.                  BEGIN(INITIAL);
  1016.                  }
  1017.  
  1018.          <<EOF>> {
  1019.                  if ( --include_stack_ptr < 0 )
  1020.                      {
  1021.                      yyterminate();
  1022.                      }
  1023.  
  1024.                  else
  1025.                      yy_switch_to_buffer(
  1026.                           include_stack[include_stack_ptr] );
  1027.                  }
  1028.  
  1029.  
  1030.    END-OF-FILE RULES
  1031.      The special rule "<<EOF>>" indicates actions which are to be taken when
  1032.      an end-of-file is encountered and yywrap() returns non-zero (i.e., indi-
  1033.      cates no further files to process).  The action must finish by doing one
  1034.      of four things:
  1035.  
  1036.      -    the special YY_NEW_FILE action, if yyin has been pointed at a new
  1037.           file to process;
  1038.  
  1039.      -    a return statement;
  1040.  
  1041.      -    the special yyterminate() action;
  1042.  
  1043.      -    or, switching to a new buffer using yy_switch_to_buffer() as shown
  1044.           in the example above.
  1045.  
  1046.      <<EOF>> rules may not be used with other patterns; they may only be
  1047.      qualified with a list of start conditions.  If an unqualified <<EOF>>
  1048.      rule is given, it applies to all start conditions which do not already
  1049.      have <<EOF>> actions.  To specify an <<EOF>> rule for only the initial
  1050.      start condition, use
  1051.  
  1052.  
  1053.    16                                                             Version 2.3
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.    26 May 1990                                                        FLEX(1)
  1061.  
  1062.  
  1063.  
  1064.          <INITIAL><<EOF>>
  1065.  
  1066.  
  1067.      These rules are useful for catching things like unclosed comments.  An
  1068.      example:
  1069.  
  1070.          %x quote
  1071.          %%
  1072.  
  1073.          ...other rules for dealing with quotes...
  1074.  
  1075.          <quote><<EOF>>   {
  1076.                   error( "unterminated quote" );
  1077.                   yyterminate();
  1078.                   }
  1079.          <<EOF>>  {
  1080.                   if ( *++filelist )
  1081.                       {
  1082.                       yyin = fopen( *filelist, "r" );
  1083.                       YY_NEW_FILE;
  1084.                       }
  1085.                   else
  1086.                      yyterminate();
  1087.                   }
  1088.  
  1089.  
  1090.    MISCELLANEOUS MACROS
  1091.      The macro YY_USER_ACTION can be redefined to provide an action which is
  1092.      always executed prior to the matched rule's action.  For example, it
  1093.      could be #define'd to call a routine to convert yytext to lower-case.
  1094.  
  1095.      The macro YY_USER_INIT may be redefined to provide an action which is
  1096.      always executed before the first scan (and before the scanner's internal
  1097.      initializations are done).  For example, it could be used to call a rou-
  1098.      tine to read in a data table or open a logging file.
  1099.  
  1100.      In the generated scanner, the actions are all gathered in one large
  1101.      switch statement and separated using YY_BREAK, which may be redefined.
  1102.      By default, it is simply a "break", to separate each rule's action from
  1103.      the following rule's.  Redefining YY_BREAK allows, for example, C++
  1104.      users to #define YY_BREAK to do nothing (while being very careful that
  1105.      every rule ends with a "break" or a "return"!) to avoid suffering from
  1106.      unreachable statement warnings where because a rule's action ends with
  1107.      "return", the YY_BREAK is inaccessible.
  1108.  
  1109.    INTERFACING WITH YACC
  1110.      One of the main uses of flex is as a companion to the yacc parser-
  1111.      generator.  yacc parsers expect to call a routine named yylex() to find
  1112.      the next input token.  The routine is supposed to return the type of the
  1113.      next token as well as putting any associated value in the global yylval.
  1114.      To use flex with yacc, one specifies the -d option to yacc to instruct
  1115.      it to generate the file y.tab.h containing definitions of all the
  1116.      %tokens appearing in the yacc input.  This file is then included in the
  1117.  
  1118.  
  1119.    Version 2.3                                                             17
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.    FLEX(1)                                                        26 May 1990
  1127.  
  1128.  
  1129.      flex scanner.  For example, if one of the tokens is "TOK_NUMBER", part
  1130.      of the scanner might look like:
  1131.  
  1132.          %{
  1133.          #include "y.tab.h"
  1134.          %}
  1135.  
  1136.          %%
  1137.  
  1138.          [0-9]+        yylval = atoi( yytext ); return TOK_NUMBER;
  1139.  
  1140.  
  1141.    TRANSLATION TABLE
  1142.      In the name of POSIX compliance, flex supports a translation table for
  1143.      mapping input characters into groups.  The table is specified in the
  1144.      first section, and its format looks like:
  1145.  
  1146.          %t
  1147.          1        abcd
  1148.          2        ABCDEFGHIJKLMNOPQRSTUVWXYZ
  1149.          52       0123456789
  1150.          6        \t\ \n
  1151.          %t
  1152.  
  1153.      This example specifies that the characters 'a', 'b', 'c', and 'd' are to
  1154.      all be lumped into group #1, upper-case letters in group #2, digits in
  1155.      group #52, tabs, blanks, and newlines into group #6, and no other char-
  1156.      acters will appear in the patterns.  The group numbers are actually
  1157.      disregarded by flex; %t serves, though, to lump characters together.
  1158.      Given the above table, for example, the pattern "a(AA)*5" is equivalent
  1159.      to "d(ZQ)*0".  They both say, "match any character in group #1, followed
  1160.      by zero-or-more pairs of characters from group #2, followed by a charac-
  1161.      ter from group #52."  Thus %t provides a crude way for introducing
  1162.      equivalence classes into the scanner specification.
  1163.  
  1164.      Note that the -i option (see below) coupled with the equivalence classes
  1165.      which flex automatically generates take care of virtually all the
  1166.      instances when one might consider using %t. But what the hell, it's
  1167.      there if you want it.
  1168.  
  1169.    OPTIONS
  1170.      flex has the following options:
  1171.  
  1172.      -b   Generate backtracking information to lex.backtrack. This is a list
  1173.           of scanner states which require backtracking and the input charac-
  1174.           ters on which they do so.  By adding rules one can remove back-
  1175.           tracking states.  If all backtracking states are eliminated and -f
  1176.           or -F is used, the generated scanner will run faster (see the -p
  1177.           flag).  Only users who wish to squeeze every last cycle out of
  1178.           their scanners need worry about this option.  (See the section on
  1179.           PERFORMANCE CONSIDERATIONS below.)
  1180.  
  1181.      -c   is a do-nothing, deprecated option included for POSIX compliance.
  1182.  
  1183.  
  1184.  
  1185.    18                                                             Version 2.3
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.    26 May 1990                                                        FLEX(1)
  1193.  
  1194.  
  1195.           NOTE: in previous releases of flex -c specified table-compression
  1196.           options.  This functionality is now given by the -C flag.  To ease
  1197.           the the impact of this change, when flex encounters -c, it
  1198.           currently issues a warning message and assumes that -C was desired
  1199.           instead.  In the future this "promotion" of -c to -C will go away
  1200.           in the name of full POSIX compliance (unless the POSIX meaning is
  1201.           removed first).
  1202.  
  1203.      -d   makes the generated scanner run in debug mode.  Whenever a pattern
  1204.           is recognized and the global yy_flex_debug is non-zero (which is
  1205.           the default), the scanner will write to stderr a line of the form:
  1206.  
  1207.               --accepting rule at line 53 ("the matched text")
  1208.  
  1209.           The line number refers to the location of the rule in the file
  1210.           defining the scanner (i.e., the file that was fed to flex).  Mes-
  1211.           sages are also generated when the scanner backtracks, accepts the
  1212.           default rule, reaches the end of its input buffer (or encounters a
  1213.           NUL; at this point, the two look the same as far as the scanner's
  1214.           concerned), or reaches an end-of-file.
  1215.  
  1216.      -f   specifies (take your pick) full table or fast scanner. No table
  1217.           compression is done.  The result is large but fast.  This option is
  1218.           equivalent to -Cf (see below).
  1219.  
  1220.      -i   instructs flex to generate a case-insensitive scanner.  The case of
  1221.           letters given in the flex input patterns will be ignored, and
  1222.           tokens in the input will be matched regardless of case.  The
  1223.           matched text given in yytext will have the preserved case (i.e., it
  1224.           will not be folded).
  1225.  
  1226.      -n   is another do-nothing, deprecated option included only for POSIX
  1227.           compliance.
  1228.  
  1229.      -p   generates a performance report to stderr.  The report consists of
  1230.           comments regarding features of the flex input file which will cause
  1231.           a loss of performance in the resulting scanner.  Note that the use
  1232.           of REJECT and variable trailing context (see the BUGS section in
  1233.           flex(1)) entails a substantial performance penalty; use of
  1234.           yymore(), the ^ operator, and the -I flag entail minor performance
  1235.           penalties.
  1236.  
  1237.      -s   causes the default rule (that unmatched scanner input is echoed to
  1238.           stdout) to be suppressed.  If the scanner encounters input that
  1239.           does not match any of its rules, it aborts with an error.  This
  1240.           option is useful for finding holes in a scanner's rule set.
  1241.  
  1242.      -t   instructs flex to write the scanner it generates to standard output
  1243.           instead of lex.yy.c.
  1244.  
  1245.      -v   specifies that flex should write to stderr a summary of statistics
  1246.           regarding the scanner it generates.  Most of the statistics are
  1247.           meaningless to the casual flex user, but the first line identifies
  1248.           the version of flex, which is useful for figuring out where you
  1249.  
  1250.  
  1251.    Version 2.3                                                             19
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.    FLEX(1)                                                        26 May 1990
  1259.  
  1260.  
  1261.           stand with respect to patches and new releases, and the next two
  1262.           lines give the date when the scanner was created and a summary of
  1263.           the flags which were in effect.
  1264.  
  1265.      -F   specifies that the fast scanner table representation should be
  1266.           used.  This representation is about as fast as the full table
  1267.           representation (-f), and for some sets of patterns will be consid-
  1268.           erably smaller (and for others, larger).  In general, if the pat-
  1269.           tern set contains both "keywords" and a catch-all, "identifier"
  1270.           rule, such as in the set:
  1271.  
  1272.               "case"    return TOK_CASE;
  1273.               "switch"  return TOK_SWITCH;
  1274.               ...
  1275.               "default" return TOK_DEFAULT;
  1276.               [a-z]+    return TOK_ID;
  1277.  
  1278.           then you're better off using the full table representation.  If
  1279.           only the "identifier" rule is present and you then use a hash table
  1280.           or some such to detect the keywords, you're better off using -F.
  1281.  
  1282.           This option is equivalent to -CF (see below).
  1283.  
  1284.      -I   instructs flex to generate an interactive scanner.  Normally,
  1285.           scanners generated by flex always look ahead one character before
  1286.           deciding that a rule has been matched.  At the cost of some scan-
  1287.           ning overhead, flex will generate a scanner which only looks ahead
  1288.           when needed.  Such scanners are called interactive because if you
  1289.           want to write a scanner for an interactive system such as a command
  1290.           shell, you will probably want the user's input to be terminated
  1291.           with a newline, and without -I the user will have to type a charac-
  1292.           ter in addition to the newline in order to have the newline recog-
  1293.           nized.  This leads to dreadful interactive performance.
  1294.  
  1295.           If all this seems to confusing, here's the general rule: if a human
  1296.           will be typing in input to your scanner, use -I, otherwise don't;
  1297.           if you don't care about squeezing the utmost performance from your
  1298.           scanner and you don't want to make any assumptions about the input
  1299.           to your scanner, use -I.
  1300.  
  1301.           Note, -I cannot be used in conjunction with full or fast tables,
  1302.           i.e., the -f, -F, -Cf, or -CF flags.
  1303.  
  1304.      -L   instructs flex not to generate #line directives.  Without this
  1305.           option, flex peppers the generated scanner with #line directives so
  1306.           error messages in the actions will be correctly located with
  1307.           respect to the original flex input file, and not to the fairly
  1308.           meaningless line numbers of lex.yy.c. (Unfortunately flex does not
  1309.           presently generate the necessary directives to "retarget" the line
  1310.           numbers for those parts of lex.yy.c which it generated.  So if
  1311.           there is an error in the generated code, a meaningless line number
  1312.           is reported.)
  1313.  
  1314.      -T   makes flex run in trace mode.  It will generate a lot of messages
  1315.  
  1316.  
  1317.    20                                                             Version 2.3
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.    26 May 1990                                                        FLEX(1)
  1325.  
  1326.  
  1327.           to stdout concerning the form of the input and the resultant non-
  1328.           deterministic and deterministic finite automata.  This option is
  1329.           mostly for use in maintaining flex.
  1330.  
  1331.      -8   instructs flex to generate an 8-bit scanner, i.e., one which can
  1332.           recognize 8-bit characters.  On some sites, flex is installed with
  1333.           this option as the default.  On others, the default is 7-bit char-
  1334.           acters.  To see which is the case, check the verbose (-v) output
  1335.           for "equivalence classes created".  If the denominator of the
  1336.           number shown is 128, then by default flex is generating 7-bit char-
  1337.           acters.  If it is 256, then the default is 8-bit characters and the
  1338.           -8 flag is not required (but may be a good idea to keep the scanner
  1339.           specification portable).  Feeding a 7-bit scanner 8-bit characters
  1340.           will result in infinite loops, bus errors, or other such fireworks,
  1341.           so when in doubt, use the flag.  Note that if equivalence classes
  1342.           are used, 8-bit scanners take only slightly more table space than
  1343.           7-bit scanners (128 bytes, to be exact); if equivalence classes are
  1344.           not used, however, then the tables may grow up to twice their 7-bit
  1345.           size.
  1346.  
  1347.      -C[efmF]
  1348.           controls the degree of table compression.
  1349.  
  1350.           -Ce directs flex to construct equivalence classes, i.e., sets of
  1351.           characters which have identical lexical properties (for example, if
  1352.           the only appearance of digits in the flex input is in the character
  1353.           class "[0-9]" then the digits '0', '1', ..., '9' will all be put in
  1354.           the same equivalence class).  Equivalence classes usually give
  1355.           dramatic reductions in the final table/object file sizes (typically
  1356.           a factor of 2-5) and are pretty cheap performance-wise (one array
  1357.           look-up per character scanned).
  1358.  
  1359.           -Cf specifies that the full scanner tables should be generated -
  1360.           flex should not compress the tables by taking advantages of similar
  1361.           transition functions for different states.
  1362.  
  1363.           -CF specifies that the alternate fast scanner representation
  1364.           (described above under the -F flag) should be used.
  1365.  
  1366.           -Cm directs flex to construct meta-equivalence classes, which are
  1367.           sets of equivalence classes (or characters, if equivalence classes
  1368.           are not being used) that are commonly used together.  Meta-
  1369.           equivalence classes are often a big win when using compressed
  1370.           tables, but they have a moderate performance impact (one or two
  1371.           "if" tests and one array look-up per character scanned).
  1372.  
  1373.           A lone -C specifies that the scanner tables should be compressed
  1374.           but neither equivalence classes nor meta-equivalence classes should
  1375.           be used.
  1376.  
  1377.           The options -Cf or -CF and -Cm do not make sense together - there
  1378.           is no opportunity for meta-equivalence classes if the table is not
  1379.           being compressed.  Otherwise the options may be freely mixed.
  1380.  
  1381.  
  1382.  
  1383.    Version 2.3                                                             21
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.    FLEX(1)                                                        26 May 1990
  1391.  
  1392.  
  1393.           The default setting is -Cem, which specifies that flex should gen-
  1394.           erate equivalence classes and meta-equivalence classes.  This set-
  1395.           ting provides the highest degree of table compression.  You can
  1396.           trade off faster-executing scanners at the cost of larger tables
  1397.           with the following generally being true:
  1398.  
  1399.               slowest & smallest
  1400.                     -Cem
  1401.                     -Cm
  1402.                     -Ce
  1403.                     -C
  1404.                     -C{f,F}e
  1405.                     -C{f,F}
  1406.               fastest & largest
  1407.  
  1408.           Note that scanners with the smallest tables are usually generated
  1409.           and compiled the quickest, so during development you will usually
  1410.           want to use the default, maximal compression.
  1411.  
  1412.           -Cfe is often a good compromise between speed and size for produc-
  1413.           tion scanners.
  1414.  
  1415.           -C options are not cumulative; whenever the flag is encountered,
  1416.           the previous -C settings are forgotten.
  1417.  
  1418.      -Sskeleton_file
  1419.           overrides the default skeleton file from which flex constructs its
  1420.           scanners.  You'll never need this option unless you are doing flex
  1421.           maintenance or development.
  1422.  
  1423.    PERFORMANCE CONSIDERATIONS
  1424.      The main design goal of flex is that it generate high-performance
  1425.      scanners.  It has been optimized for dealing well with large sets of
  1426.      rules.  Aside from the effects of table compression on scanner speed
  1427.      outlined above, there are a number of options/actions which degrade per-
  1428.      formance.  These are, from most expensive to least:
  1429.  
  1430.          REJECT
  1431.  
  1432.          pattern sets that require backtracking
  1433.          arbitrary trailing context
  1434.  
  1435.          '^' beginning-of-line operator
  1436.          yymore()
  1437.  
  1438.      with the first three all being quite expensive and the last two being
  1439.      quite cheap.
  1440.  
  1441.      REJECT should be avoided at all costs when performance is important.  It
  1442.      is a particularly expensive option.
  1443.  
  1444.      Getting rid of backtracking is messy and often may be an enormous amount
  1445.      of work for a complicated scanner.  In principal, one begins by using
  1446.      the -b flag to generate a lex.backtrack file.  For example, on the input
  1447.  
  1448.  
  1449.    22                                                             Version 2.3
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.    26 May 1990                                                        FLEX(1)
  1457.  
  1458.  
  1459.  
  1460.          %%
  1461.          foo        return TOK_KEYWORD;
  1462.          foobar     return TOK_KEYWORD;
  1463.  
  1464.      the file looks like:
  1465.  
  1466.          State #6 is non-accepting -
  1467.           associated rule line numbers:
  1468.                 2       3
  1469.           out-transitions: [ o ]
  1470.           jam-transitions: EOF [ \001-n  p-\177 ]
  1471.  
  1472.          State #8 is non-accepting -
  1473.           associated rule line numbers:
  1474.                 3
  1475.           out-transitions: [ a ]
  1476.           jam-transitions: EOF [ \001-`  b-\177 ]
  1477.  
  1478.          State #9 is non-accepting -
  1479.           associated rule line numbers:
  1480.                 3
  1481.           out-transitions: [ r ]
  1482.           jam-transitions: EOF [ \001-q  s-\177 ]
  1483.  
  1484.          Compressed tables always backtrack.
  1485.  
  1486.      The first few lines tell us that there's a scanner state in which it can
  1487.      make a transition on an 'o' but not on any other character, and that in
  1488.      that state the currently scanned text does not match any rule.  The
  1489.      state occurs when trying to match the rules found at lines 2 and 3 in
  1490.      the input file.  If the scanner is in that state and then reads some-
  1491.      thing other than an 'o', it will have to backtrack to find a rule which
  1492.      is matched.  With a bit of headscratching one can see that this must be
  1493.      the state it's in when it has seen "fo".  When this has happened, if
  1494.      anything other than another 'o' is seen, the scanner will have to back
  1495.      up to simply match the 'f' (by the default rule).
  1496.  
  1497.      The comment regarding State #8 indicates there's a problem when "foob"
  1498.      has been scanned.  Indeed, on any character other than a 'b', the
  1499.      scanner will have to back up to accept "foo".  Similarly, the comment
  1500.      for State #9 concerns when "fooba" has been scanned.
  1501.  
  1502.      The final comment reminds us that there's no point going to all the
  1503.      trouble of removing backtracking from the rules unless we're using -f or
  1504.      -F, since there's no performance gain doing so with compressed scanners.
  1505.  
  1506.      The way to remove the backtracking is to add "error" rules:
  1507.  
  1508.          %%
  1509.          foo         return TOK_KEYWORD;
  1510.          foobar      return TOK_KEYWORD;
  1511.  
  1512.          fooba       |
  1513.  
  1514.  
  1515.    Version 2.3                                                             23
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.    FLEX(1)                                                        26 May 1990
  1523.  
  1524.  
  1525.          foob        |
  1526.          fo          {
  1527.                      /* false alarm, not really a keyword */
  1528.                      return TOK_ID;
  1529.                      }
  1530.  
  1531.  
  1532.      Eliminating backtracking among a list of keywords can also be done using
  1533.      a "catch-all" rule:
  1534.  
  1535.          %%
  1536.          foo         return TOK_KEYWORD;
  1537.          foobar      return TOK_KEYWORD;
  1538.  
  1539.          [a-z]+      return TOK_ID;
  1540.  
  1541.      This is usually the best solution when appropriate.
  1542.  
  1543.      Backtracking messages tend to cascade.  With a complicated set of rules
  1544.      it's not uncommon to get hundreds of messages.  If one can decipher
  1545.      them, though, it often only takes a dozen or so rules to eliminate the
  1546.      backtracking (though it's easy to make a mistake and have an error rule
  1547.      accidentally match a valid token.  A possible future flex feature will
  1548.      be to automatically add rules to eliminate backtracking).
  1549.  
  1550.      Variable trailing context (where both the leading and trailing parts do
  1551.      not have a fixed length) entails almost the same performance loss as
  1552.      REJECT (i.e., substantial).  So when possible a rule like:
  1553.  
  1554.          %%
  1555.          mouse|rat/(cat|dog)   run();
  1556.  
  1557.      is better written:
  1558.  
  1559.          %%
  1560.          mouse/cat|dog         run();
  1561.          rat/cat|dog           run();
  1562.  
  1563.      or as
  1564.  
  1565.          %%
  1566.          mouse|rat/cat         run();
  1567.          mouse|rat/dog         run();
  1568.  
  1569.      Note that here the special '|' action does not provide any savings, and
  1570.      can even make things worse (see BUGS in flex(1)).
  1571.  
  1572.      Another area where the user can increase a scanner's performance (and
  1573.      one that's easier to implement) arises from the fact that the longer the
  1574.      tokens matched, the faster the scanner will run.  This is because with
  1575.      long tokens the processing of most input characters takes place in the
  1576.      (short) inner scanning loop, and does not often have to go through the
  1577.      additional work of setting up the scanning environment (e.g., yytext)
  1578.      for the action.  Recall the scanner for C comments:
  1579.  
  1580.  
  1581.    24                                                             Version 2.3
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.    26 May 1990                                                        FLEX(1)
  1589.  
  1590.  
  1591.  
  1592.          %x comment
  1593.          %%
  1594.                  int line_num = 1;
  1595.  
  1596.          "/*"         BEGIN(comment);
  1597.  
  1598.          <comment>[^*\n]*
  1599.          <comment>"*"+[^*/\n]*
  1600.          <comment>\n             ++line_num;
  1601.          <comment>"*"+"/"        BEGIN(INITIAL);
  1602.  
  1603.      This could be sped up by writing it as:
  1604.  
  1605.          %x comment
  1606.          %%
  1607.                  int line_num = 1;
  1608.  
  1609.          "/*"         BEGIN(comment);
  1610.  
  1611.          <comment>[^*\n]*
  1612.          <comment>[^*\n]*\n      ++line_num;
  1613.          <comment>"*"+[^*/\n]*
  1614.          <comment>"*"+[^*/\n]*\n ++line_num;
  1615.          <comment>"*"+"/"        BEGIN(INITIAL);
  1616.  
  1617.      Now instead of each newline requiring the processing of another action,
  1618.      recognizing the newlines is "distributed" over the other rules to keep
  1619.      the matched text as long as possible.  Note that adding rules does not
  1620.      slow down the scanner!  The speed of the scanner is independent of the
  1621.      number of rules or (modulo the considerations given at the beginning of
  1622.      this section) how complicated the rules are with regard to operators
  1623.      such as '*' and '|'.
  1624.  
  1625.      A final example in speeding up a scanner: suppose you want to scan
  1626.      through a file containing identifiers and keywords, one per line and
  1627.      with no other extraneous characters, and recognize all the keywords.  A
  1628.      natural first approach is:
  1629.  
  1630.          %%
  1631.          asm      |
  1632.          auto     |
  1633.          break    |
  1634.          ... etc ...
  1635.          volatile |
  1636.          while    /* it's a keyword */
  1637.  
  1638.          .|\n     /* it's not a keyword */
  1639.  
  1640.      To eliminate the back-tracking, introduce a catch-all rule:
  1641.  
  1642.          %%
  1643.          asm      |
  1644.          auto     |
  1645.  
  1646.  
  1647.    Version 2.3                                                             25
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.    FLEX(1)                                                        26 May 1990
  1655.  
  1656.  
  1657.          break    |
  1658.          ... etc ...
  1659.          volatile |
  1660.          while    /* it's a keyword */
  1661.  
  1662.          [a-z]+   |
  1663.          .|\n     /* it's not a keyword */
  1664.  
  1665.      Now, if it's guaranteed that there's exactly one word per line, then we
  1666.      can reduce the total number of matches by a half by merging in the
  1667.      recognition of newlines with that of the other tokens:
  1668.  
  1669.          %%
  1670.          asm\n    |
  1671.          auto\n   |
  1672.          break\n  |
  1673.          ... etc ...
  1674.          volatile\n |
  1675.          while\n  /* it's a keyword */
  1676.  
  1677.          [a-z]+\n |
  1678.          .|\n     /* it's not a keyword */
  1679.  
  1680.      One has to be careful here, as we have now reintroduced backtracking
  1681.      into the scanner.  In particular, while we know that there will never be
  1682.      any characters in the input stream other than letters or newlines, flex
  1683.      can't figure this out, and it will plan for possibly needing backtrack-
  1684.      ing when it has scanned a token like "auto" and then the next character
  1685.      is something other than a newline or a letter.  Previously it would then
  1686.      just match the "auto" rule and be done, but now it has no "auto" rule,
  1687.      only a "auto\n" rule.  To eliminate the possibility of backtracking, we
  1688.      could either duplicate all rules but without final newlines, or, since
  1689.      we never expect to encounter such an input and therefore don't how it's
  1690.      classified, we can introduce one more catch-all rule, this one which
  1691.      doesn't include a newline:
  1692.  
  1693.          %%
  1694.          asm\n    |
  1695.          auto\n   |
  1696.          break\n  |
  1697.          ... etc ...
  1698.          volatile\n |
  1699.          while\n  /* it's a keyword */
  1700.  
  1701.          [a-z]+\n |
  1702.          [a-z]+   |
  1703.          .|\n     /* it's not a keyword */
  1704.  
  1705.      Compiled with -Cf, this is about as fast as one can get a flex scanner
  1706.      to go for this particular problem.
  1707.  
  1708.      A final note: flex is slow when matching NUL's, particularly when a
  1709.      token contains multiple NUL's.  It's best to write rules which match
  1710.      short amounts of text if it's anticipated that the text will often
  1711.  
  1712.  
  1713.    26                                                             Version 2.3
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.    26 May 1990                                                        FLEX(1)
  1721.  
  1722.  
  1723.      include NUL's.
  1724.  
  1725.    INCOMPATIBILITIES WITH LEX AND POSIX
  1726.      flex is a rewrite of the Unix lex tool (the two implementations do not
  1727.      share any code, though), with some extensions and incompatibilities,
  1728.      both of which are of concern to those who wish to write scanners accept-
  1729.      able to either implementation.  At present, the POSIX lex draft is very
  1730.      close to the original lex implementation, so some of these incompatibil-
  1731.      ities are also in conflict with the POSIX draft.  But the intent is that
  1732.      except as noted below, flex as it presently stands will ultimately be
  1733.      POSIX conformant (i.e., that those areas of conflict with the POSIX
  1734.      draft will be resolved in flex's favor).  Please bear in mind that all
  1735.      the comments which follow are with regard to the POSIX draft standard of
  1736.      Summer 1989, and not the final document (or subsequent drafts); they are
  1737.      included so flex users can be aware of the standardization issues and
  1738.      those areas where flex may in the near future undergo changes incompati-
  1739.      ble with its current definition.
  1740.  
  1741.      flex is fully compatible with lex with the following exceptions:
  1742.  
  1743.      -    The undocumented lex scanner internal variable yylineno is not sup-
  1744.           ported.  It is difficult to support this option efficiently, since
  1745.           it requires examining every character scanned and reexamining the
  1746.           characters when the scanner backs up.  Things get more complicated
  1747.           when the end of buffer or file is reached or a NUL is scanned
  1748.           (since the scan must then be restarted with the proper line number
  1749.           count), or the user uses the yyless(), unput(), or REJECT actions,
  1750.           or the multiple input buffer functions.
  1751.  
  1752.           The fix is to add rules which, upon seeing a newline, increment
  1753.           yylineno.  This is usually an easy process, though it can be a drag
  1754.           if some of the patterns can match multiple newlines along with
  1755.           other characters.
  1756.  
  1757.           yylineno is not part of the POSIX draft.
  1758.  
  1759.      -    The input() routine is not redefinable, though it may be called to
  1760.           read characters following whatever has been matched by a rule.  If
  1761.           input() encounters an end-of-file the normal yywrap() processing is
  1762.           done.  A ``real'' end-of-file is returned by input() as EOF.
  1763.  
  1764.           Input is instead controlled by redefining the YY_INPUT macro.
  1765.  
  1766.           The flex restriction that input() cannot be redefined is in accor-
  1767.           dance with the POSIX draft, but YY_INPUT has not yet been accepted
  1768.           into the draft (and probably won't; it looks like the draft will
  1769.           simply not specify any way of controlling the scanner's input other
  1770.           than by making an initial assignment to yyin).
  1771.  
  1772.      -    flex scanners do not use stdio for input.  Because of this, when
  1773.           writing an interactive scanner one must explicitly call fflush() on
  1774.           the stream associated with the terminal after writing out a prompt.
  1775.           With lex such writes are automatically flushed since lex scanners
  1776.           use getchar() for their input.  Also, when writing interactive
  1777.  
  1778.  
  1779.    Version 2.3                                                             27
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.    FLEX(1)                                                        26 May 1990
  1787.  
  1788.  
  1789.           scanners with flex, the -I flag must be used.
  1790.  
  1791.      -    flex scanners are not as reentrant as lex scanners.  In particular,
  1792.           if you have an interactive scanner and an interrupt handler which
  1793.           long-jumps out of the scanner, and the scanner is subsequently
  1794.           called again, you may get the following message:
  1795.  
  1796.               fatal flex scanner internal error--end of buffer missed
  1797.  
  1798.           To reenter the scanner, first use
  1799.  
  1800.               yyrestart( yyin );
  1801.  
  1802.  
  1803.      -    output() is not supported.  Output from the ECHO macro is done to
  1804.           the file-pointer yyout (default stdout).
  1805.  
  1806.           The POSIX draft mentions that an output() routine exists but
  1807.           currently gives no details as to what it does.
  1808.  
  1809.      -    lex does not support exclusive start conditions (%x), though they
  1810.           are in the current POSIX draft.
  1811.  
  1812.      -    When definitions are expanded, flex encloses them in parentheses.
  1813.           With lex, the following:
  1814.  
  1815.               NAME    [A-Z][A-Z0-9]*
  1816.               %%
  1817.               foo{NAME}?      printf( "Found it\n" );
  1818.               %%
  1819.  
  1820.           will not match the string "foo" because when the macro is expanded
  1821.           the rule is equivalent to "foo[A-Z][A-Z0-9]*?" and the precedence
  1822.           is such that the '?' is associated with "[A-Z0-9]*".  With flex,
  1823.           the rule will be expanded to "foo([A-Z][A-Z0-9]*)?" and so the
  1824.           string "foo" will match.  Note that because of this, the ^, $, <s>,
  1825.           /, and <<EOF>> operators cannot be used in a flex definition.
  1826.  
  1827.           The POSIX draft interpretation is the same as flex's.
  1828.  
  1829.      -    To specify a character class which matches anything but a left
  1830.           bracket (']'), in lex one can use "[^]]" but with flex one must use
  1831.           "[^\]]".  The latter works with lex, too.
  1832.  
  1833.      -    The lex %r (generate a Ratfor scanner) option is not supported.  It
  1834.           is not part of the POSIX draft.
  1835.  
  1836.      -    If you are providing your own yywrap() routine, you must include a
  1837.           "#undef yywrap" in the definitions section (section 1).  Note that
  1838.           the "#undef" will have to be enclosed in %{}'s.
  1839.  
  1840.           The POSIX draft specifies that yywrap() is a function and this is
  1841.           very unlikely to change; so flex users are warned that yywrap() is
  1842.           likely to be changed to a function in the near future.
  1843.  
  1844.  
  1845.    28                                                             Version 2.3
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.    26 May 1990                                                        FLEX(1)
  1853.  
  1854.  
  1855.      -    After a call to unput(), yytext and yyleng are undefined until the
  1856.           next token is matched.  This is not the case with lex or the
  1857.           present POSIX draft.
  1858.  
  1859.      -    The precedence of the {} (numeric range) operator is different.
  1860.           lex interprets "abc{1,3}" as "match one, two, or three occurrences
  1861.           of 'abc'", whereas flex interprets it as "match 'ab' followed by
  1862.           one, two, or three occurrences of 'c'".  The latter is in agreement
  1863.           with the current POSIX draft.
  1864.  
  1865.      -    The precedence of the ^ operator is different.  lex interprets
  1866.           "^foo|bar" as "match either 'foo' at the beginning of a line, or
  1867.           'bar' anywhere", whereas flex interprets it as "match either 'foo'
  1868.           or 'bar' if they come at the beginning of a line".  The latter is
  1869.           in agreement with the current POSIX draft.
  1870.  
  1871.      -    To refer to yytext outside of the scanner source file, the correct
  1872.           definition with flex is "extern char *yytext" rather than "extern
  1873.           char yytext[]".  This is contrary to the current POSIX draft but a
  1874.           point on which flex will not be changing, as the array representa-
  1875.           tion entails a serious performance penalty.  It is hoped that the
  1876.           POSIX draft will be emended to support the flex variety of declara-
  1877.           tion (as this is a fairly painless change to require of lex users).
  1878.  
  1879.      -    yyin is initialized by lex to be stdin; flex, on the other hand,
  1880.           initializes yyin to NULL and then assigns it to stdin the first
  1881.           time the scanner is called, providing yyin has not already been
  1882.           assigned to a non-NULL value.  The difference is subtle, but the
  1883.           net effect is that with flex scanners, yyin does not have a valid
  1884.           value until the scanner has been called.
  1885.  
  1886.      -    The special table-size declarations such as %a supported by lex are
  1887.           not required by flex scanners; flex ignores them.
  1888.  
  1889.      -    The name FLEX_SCANNER is #define'd so scanners may be written for
  1890.           use with either flex or lex.
  1891.  
  1892.      The following flex features are not included in lex or the POSIX draft
  1893.      standard:
  1894.  
  1895.          yyterminate()
  1896.          <<EOF>>
  1897.          YY_DECL
  1898.          #line directives
  1899.          %{}'s around actions
  1900.          yyrestart()
  1901.          comments beginning with '#' (deprecated)
  1902.          multiple actions on a line
  1903.  
  1904.      This last feature refers to the fact that with flex you can put multiple
  1905.      actions on the same line, separated with semi-colons, while with lex,
  1906.      the following
  1907.  
  1908.          foo    handle_foo(); ++num_foos_seen;
  1909.  
  1910.  
  1911.    Version 2.3                                                             29
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.    FLEX(1)                                                        26 May 1990
  1919.  
  1920.  
  1921.  
  1922.      is (rather surprisingly) truncated to
  1923.  
  1924.          foo    handle_foo();
  1925.  
  1926.      flex does not truncate the action.  Actions that are not enclosed in
  1927.      braces are simply terminated at the end of the line.
  1928.  
  1929.    DIAGNOSTICS
  1930.      reject_used_but_not_detected undefined or yymore_used_but_not_detected
  1931.      undefined - These errors can occur at compile time.  They indicate that
  1932.      the scanner uses REJECT or yymore() but that flex failed to notice the
  1933.      fact, meaning that flex scanned the first two sections looking for
  1934.      occurrences of these actions and failed to find any, but somehow you
  1935.      snuck some in (via a #include file, for example).  Make an explicit
  1936.      reference to the action in your flex input file.  (Note that previously
  1937.      flex supported a %used/%unused mechanism for dealing with this problem;
  1938.      this feature is still supported but now deprecated, and will go away
  1939.      soon unless the author hears from people who can argue compellingly that
  1940.      they need it.)
  1941.  
  1942.      flex scanner jammed - a scanner compiled with -s has encountered an
  1943.      input string which wasn't matched by any of its rules.
  1944.  
  1945.      flex input buffer overflowed - a scanner rule matched a string long
  1946.      enough to overflow the scanner's internal input buffer (16K bytes by
  1947.      default - controlled by YY_BUF_SIZE in "flex.skel".  Note that to rede-
  1948.      fine this macro, you must first #undefine it).
  1949.  
  1950.      scanner requires -8 flag - Your scanner specification includes recogniz-
  1951.      ing 8-bit characters and you did not specify the -8 flag (and your site
  1952.      has not installed flex with -8 as the default).
  1953.  
  1954.      fatal flex scanner internal error--end of buffer missed - This can occur
  1955.      in an scanner which is reentered after a long-jump has jumped out (or
  1956.      over) the scanner's activation frame.  Before reentering the scanner,
  1957.      use:
  1958.  
  1959.          yyrestart( yyin );
  1960.  
  1961.  
  1962.      too many %t classes! - You managed to put every single character into
  1963.      its own %t class.  flex requires that at least one of the classes share
  1964.      characters.
  1965.  
  1966.    DEFICIENCIES / BUGS
  1967.      See flex(1).
  1968.  
  1969.    SEE ALSO
  1970.  
  1971.      flex(1), lex(1), yacc(1), sed(1), awk(1).
  1972.  
  1973.      M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator
  1974.  
  1975.  
  1976.  
  1977.    30                                                             Version 2.3
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.    26 May 1990                                                        FLEX(1)
  1985.  
  1986.  
  1987.    AUTHOR
  1988.      Vern Paxson, with the help of many ideas and much inspiration from Van
  1989.      Jacobson.  Original version by Jef Poskanzer.  The fast table represen-
  1990.      tation is a partial implementation of a design done by Van Jacobson.
  1991.      The implementation was done by Kevin Gong and Vern Paxson.
  1992.  
  1993.      Thanks to the many flex beta-testers, feedbackers, and contributors,
  1994.      especially Casey Leedom, benson@odi.com, Keith Bostic, Frederic Brehm,
  1995.      Nick Christopher, Jason Coughlin, Scott David Daniels, Leo Eskin, Chris
  1996.      Faylor, Eric Goldman, Eric Hughes, Jeffrey R. Jones, Kevin B. Kenny,
  1997.      Ronald Lamprecht, Greg Lee, Craig Leres, Mohamed el Lozy, Jim Meyering,
  1998.      Marc Nozell, Esmond Pitt, Jef Poskanzer, Jim Roskind, Dave Tallman,
  1999.      Frank Whaley, Ken Yap, and those whose names have slipped my marginal
  2000.      mail-archiving skills but whose contributions are appreciated all the
  2001.      same.
  2002.  
  2003.      Thanks to Keith Bostic, John Gilmore, Craig Leres, Bob Mulcahy, Rich
  2004.      Salz, and Richard Stallman for help with various distribution headaches.
  2005.  
  2006.      Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to
  2007.      Benson Margulies and Fred Burke for C++ support; to Ove Ewerlid for the
  2008.      basics of support for NUL's; and to Eric Hughes for the basics of sup-
  2009.      port for multiple buffers.
  2010.  
  2011.      Work is being done on extending flex to generate scanners in which the
  2012.      state machine is directly represented in C code rather than tables.
  2013.      These scanners may well be substantially faster than those generated
  2014.      using -f or -F.  If you are working in this area and are interested in
  2015.      comparing notes and seeing whether redundant work can be avoided, con-
  2016.      tact Ove Ewerlid (ewerlid@mizar.DoCS.UU.SE).
  2017.  
  2018.      This work was primarily done when I was at the Real Time Systems Group
  2019.      at the Lawrence Berkeley Laboratory in Berkeley, CA.  Many thanks to all
  2020.      there for the support I received.
  2021.  
  2022.      Send comments to:
  2023.  
  2024.           Vern Paxson
  2025.           Computer Systems Engineering
  2026.           Bldg. 46A, Room 1123
  2027.           Lawrence Berkeley Laboratory
  2028.           University of California
  2029.           Berkeley, CA 94720
  2030.  
  2031.           vern@ee.lbl.gov
  2032.           ucbvax!ee.lbl.gov!vern
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.    Version 2.3                                                             31
  2044.  
  2045.